package com.wmada.toolkit.rpc;

/**
 * @author will.ma
 * @date 2020-11-3
 */
public abstract class BufferedCmdParser<T> extends CmdParser {

    private final StringBuilder sb      = new StringBuilder();
    private final StringBuilder errorSb = new StringBuilder();

    @Override
    public void parse(String line) throws CmdParseException {
        sb.append(line).append('\n');
    }

    @Override
    public void parseError(String line) throws CmdParseException {
        errorSb.append(line).append('\n');
    }

    public StringBuilder getOutputStringBuilder() {
        return sb;
    }

    public StringBuilder getErrorStringBuilder() {
        return errorSb;
    }

    public String getOutput() {
        return sb.toString();
    }

    public String getError() {
        return errorSb.toString();
    }

    public abstract T getResult();

}
